const Koa = require('koa');
const logger = require('koa-logger');
const app = new Koa();

// x-response-time

app.use(logger())

app.use(async (ctx, a) => {
  const start = Date.now();
 a();
  const ms = Date.now() - start;
  ctx.set('X-Response-Time', `${ms}ms`);
 // console.log('X-Response-Time', `${ms}ms`);
});

// logger

app.use(async (ctx, a) => {
  const start = Date.now();
  a();
  const ms = Date.now() - start;
  //console.log(`${ctx.method} ${ctx.url} - ${ms}`);
});

// response

app.use(async ctx => {
  ctx.body = 'Hello World';
});


app.listen(3000);